Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug that accept attribute in the input field didn't work properly #2360

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

ryubro
Copy link
Contributor

@ryubro ryubro commented Sep 3, 2024

What I did

  1. Fix the bug that the accept attribute in the input field didn't work
    • When the accepted extensions have ., the IsAcceptedFile validator always fails. (It tries to compare jpg (from the accept attirbute) and .jpg (from file name)
    • When the accepted extensions doesn't have ., the file dialog disable those file with the extensions (accept="jpg" will make jpg files unselectable - actually all files become unselectible)

Technically breaking change

Apparently we officially supported extensions without . for the accept attribute, but this is not a valid accept attribute and breaks the behaviour of browsers (tested on Chrome 128.0.6613.114, Mac). So I removed the normalization (removing .) of the extension and the relevant test.

It's technically a breaking change, but it seems rather a bug fix, to me (if a consumer used extensions without ., it would break the browser behavior, anyway)

Copy link

changeset-bot bot commented Sep 3, 2024

🦋 Changeset detected

Latest commit: ac9d16b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lion/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -158,6 +158,17 @@ describe('lion-input-file', () => {
})
);

it('error should not be there when the file extensions are accepted', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was failing before the fix

@ryubro ryubro merged commit ef4ad50 into master Sep 5, 2024
7 checks passed
@ryubro ryubro deleted the fix/accept-attribute branch September 5, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants